package edu.unice.simul.vue.components.simul;

import java.awt.Font;

import javax.swing.JLabel;
import javax.swing.JPanel;

import edu.unice.simul.listeners.TimeListener;

/**
 * Panneau affichant le temps courrant dans la simulation
 * 
 * @author Romain Ciaccafava
 * 
 */
public class TimePanel extends JPanel implements TimeListener {
	private static final long serialVersionUID = 6463360846201383201L;
	private JLabel label = new JLabel("XXX");

	public TimePanel() {
		label.setFont(new Font("./res/font.ttf", Font.PLAIN, 26));
		add(label);
	}

	/**
	 * Met à jour le temps de la simulation
	 */
	@Override
	public void updateTime(long milis) {
		int time = (int) milis / 1000;
		int minutes = time / 60;
		String _minutes = minutes < 10 ? "0" + minutes : minutes + "";
		time -= minutes * 60;
		String _secondes = time < 10 ? "0" + time : time + "";
		label.setText(_minutes + ":" + _secondes);
	}
}
